package top.lyc829.aircontroller.ui.vidoeDetial;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


import java.util.List;

import top.lyc829.aircontroller.R;

public class VideoDetailAdapter extends ArrayAdapter<String> {

    private int viewId;

    public VideoDetailAdapter(@NonNull Context context, int resource, @NonNull List<String> objects) {
        super(context, resource, objects);
        this.viewId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        String name = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(viewId,null);
        TextView idText = view.findViewById(R.id.name_id);
        TextView nameText = view.findViewById(R.id.name_text);
        idText.setText("p"+position);
        nameText.setText(name);
        return view;
    }
}
